package com.auto.oa.user.service.impl;

import java.util.List;
import java.util.Map;

import com.auto.oa.user.dao.OaUserDAOFactory;
import com.auto.oa.user.domain.OaUserPost;
import com.auto.oa.user.service.IOaUserPostService;
import com.system.common.Page;
import com.system.util.BeanUtil;

public class OaUserPostServiceImpl implements IOaUserPostService {

	public List<OaUserPost> queryPageListOaUserPost(OaUserPost oaUserPost, Page page) throws Exception {
		List<OaUserPost> resultList = null;
		try {
			Map<String, Object> param = BeanUtil.convertBeanToMap(oaUserPost);
			resultList = OaUserDAOFactory.oaUserPostDAO.queryList(param, page);
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		return resultList;
	}

	public boolean saveOrUpdateOaUserPost(OaUserPost oaUserPost) throws Exception {
		boolean bool = true;
		try {
			if(BeanUtil.isObjectNotNull(oaUserPost)){
				if(BeanUtil.isBlank(oaUserPost.getAupoGuid())){
					OaUserDAOFactory.oaUserPostDAO.insertOaUserPost(oaUserPost);
				}else{
					OaUserDAOFactory.oaUserPostDAO.updateOaUserPost(oaUserPost);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		return bool;
	}

	public boolean deleteOaUserPost(String guid) throws Exception {
		boolean bool = true;
		try {
			if(!BeanUtil.isBlank(guid)){
				OaUserDAOFactory.oaUserPostDAO.deleteOaUserPost(guid);
			}else{
				bool = false;
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		return bool;
	}
	
	public boolean deleteOaUserPostByPostCode(String orgCode, String postCode) throws Exception {
		try {
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		return false;
	}

	public boolean checkPostCodeExists(String postCode) throws Exception {
		boolean bool = true;
		try {
			// TODO: handle exception
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		return bool;
	}

	public OaUserPost getOaUserPost(String guid) throws Exception {
		OaUserPost oaUserPost = null;
		try {
			oaUserPost = OaUserDAOFactory.oaUserPostDAO.loadOaUserPost(guid);
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		return oaUserPost;
	}

	public OaUserPost getOaUserPostByPostCode(String orgCode, String postCode) throws Exception {
		try {
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		return null;
	}

}
